<template>
	<view class="phone">
		<view class="add_item">
			<view>姓名</view>
			<input type="text" placeholder="请输入姓名" v-model="upJson.name"/>
		</view>
		<view class="add_item">
			<view>职位</view>
			<input type="text" value="" placeholder="请输入职位" v-model="upJson.position"/>
		</view>
		<view class="add_item">
			<view>电话</view>
			<input type="text" value="" placeholder="请输入电话" v-model="upJson.mobile"/>
		</view>
		
		<view class="save" @tap="save()">提交</view>
	</view>
</template>

<script>
	export default{
		data(){
			return{
				upJson:{
					"customer_id":"",
					"name":"",//联系人
					"mobile":"",//电话
					"position":"",//非必填
				}
			}
		},
		onLoad(options) {
			this.upJson.customer_id = options.kid;
		},
		methods:{
			save(){
				console.log(this.upJson.name.length)
				if(this.upJson.name.length == 0){
					uni.showToast({title:"姓名不能为空",icon:"none"})
				}else if(this.upJson.position.length == 0){
					uni.showToast({title:"职位不能为空",icon:"none"})
				}else if(this.upJson.mobile.length != 11){
					uni.showToast({title:"电话格式错误",icon:"none"})
				}else{
					
					this.$app.globalData.upData.clientInfo[4] = true;
					this.$api.addClientPhone(this.upJson)
				}
			}
		}
	}
</script>

<style>
	.phone{background: #FFFFFF;padding-bottom: 50upx;}
</style>
